package com.heima.article.controller.v1;


import com.heima.article.service.ApArticleService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.article.dtos.ApUserLoadDto;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
@Slf4j
@Api(value = "Ap端文章加载",tags = "Ap端文章加载")
public class ArticleHomeController {

    @Autowired
    private ApArticleService apArticleService;


    //App文章列表--首页加载
    @ApiOperation("首页加载")
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){
        return apArticleService.loadFirst(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
    }

    //App文章列表--加载更多
    @ApiOperation("加载更多")
    @PostMapping("/loadmore")
    public ResponseResult loadMove(@RequestBody ArticleHomeDto dto){
        return apArticleService.load(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
    }

    //App文章列表--加载最新
    @ApiOperation("加载最新")
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto){
        return apArticleService.load(dto, ArticleConstants.LOADTYPE_LOAD_NEW);
    }

    /**
     * 加载文章行为：数据回显
     */
    @PostMapping("/load_article_behavior")
    public ResponseResult loadArticleBehavior(@RequestBody ApUserLoadDto dto){
        return apArticleService.ApUserLoad(dto);
    }
}
